<template>
  <div>
    <FilterTable
      ref="table"
      :isSelectColumn="false"
      :columns="columns"
      height="auto"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { formatdate } from '@/utils/index';
import { qureyCareRecordPage } from '@/api/customerCare/saleVisit/potentialCustomerBirthday';

export default {
  name: 'careTask',
  mixins: [dictionary],
  components: {},
  props: {
    careTargetId: String
  },
  data() {
    return {
      columns: this.createTableColumns(),
      fetchApi: qureyCareRecordPage,
      fetchParams: {careTargetId:this.careTargetId},
      formData: {}
    };
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '客户编号',
          dataIndex: 'customerNo',
          width: 125,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '客户名称',
          dataIndex: 'customerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务编号',
          dataIndex: 'taskNo',
          width: 125,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '关爱日期',
          dataIndex: 'careDate',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            if(props.row.careDate&&props.row.careDate!=''){
              return <div>{formatdate(new Date(parseInt(props.row.careDate)), 1)}</div>;
            }
          }
        },
        {
          title: '关爱方式',
          dataIndex: 'careWay',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <div>{this.createDictText(props.row.careWay, '1587')}</div>;
          }
        },
        {
          title: '客户反馈',
          dataIndex: 'customerFeedback',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '关爱人',
          dataIndex: 'careEmpName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '关爱状态',
          dataIndex: 'careStatus',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <div>{this.createDictText(props.row.careStatus, '1592')}</div>;
          }
        },
        {
          title: '关爱失败原因',
          dataIndex: 'careFailureReason',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <div>{this.createDictText(props.row.careFailureReason, '1594')}</div>;
          }
        }
      ]
    }
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  }
};
</script>
